package com.ruoyi.project.naming.wugeanalysis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.naming.wugeanalysis.domain.WugeAnalysis;
import com.ruoyi.project.naming.wugeanalysis.service.IWugeAnalysisService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 五格配置Controller
 * 
 * @author shixiangwen
 * @date 2022-04-22
 */
@Controller
@RequestMapping("/naming/wugeanalysis")
public class WugeAnalysisController extends BaseController
{
    private String prefix = "naming/wugeanalysis";

    @Autowired
    private IWugeAnalysisService wugeAnalysisService;

    @RequiresPermissions("naming:wugeanalysis:view")
    @GetMapping()
    public String wugeanalysis()
    {
        return prefix + "/wugeanalysis";
    }

    /**
     * 查询五格配置列表
     */
    @RequiresPermissions("naming:wugeanalysis:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WugeAnalysis wugeAnalysis)
    {
        startPage();
        List<WugeAnalysis> list = wugeAnalysisService.selectWugeAnalysisList(wugeAnalysis);
        return getDataTable(list);
    }

    /**
     * 导出五格配置列表
     */
    @RequiresPermissions("naming:wugeanalysis:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WugeAnalysis wugeAnalysis)
    {
        List<WugeAnalysis> list = wugeAnalysisService.selectWugeAnalysisList(wugeAnalysis);
        ExcelUtil<WugeAnalysis> util = new ExcelUtil<WugeAnalysis>(WugeAnalysis.class);
        return util.exportExcel(list, "wugeanalysis");
    }

    /**
     * 新增五格配置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存五格配置
     */
    @RequiresPermissions("naming:wugeanalysis:add")
    @Log(title = "五格配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WugeAnalysis wugeAnalysis)
    {
        return toAjax(wugeAnalysisService.insertWugeAnalysis(wugeAnalysis));
    }

    /**
     * 修改五格配置
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WugeAnalysis wugeAnalysis = wugeAnalysisService.selectWugeAnalysisById(id);
        mmap.put("wugeAnalysis", wugeAnalysis);
        return prefix + "/edit";
    }

    /**
     * 修改保存五格配置
     */
    @RequiresPermissions("naming:wugeanalysis:edit")
    @Log(title = "五格配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WugeAnalysis wugeAnalysis)
    {
        return toAjax(wugeAnalysisService.updateWugeAnalysis(wugeAnalysis));
    }

    /**
     * 删除五格配置
     */
    @RequiresPermissions("naming:wugeanalysis:remove")
    @Log(title = "五格配置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wugeAnalysisService.deleteWugeAnalysisByIds(ids));
    }
}
